add lint workflow and fix lint issue#212
Conversation
|
@ChristopherHX I really like the project, and hope to use it in our project. Understand this is a big PR, but I think it is needed to guard each PR. |
ChristopherHX
left a comment
There was a problem hiding this comment.
Hi,
The most dangerous part is changing the protocol structure names / saved json configuration fields.
- if you add json tags
means myURL is no longer accepted by the json parser
`json:"myUrl" - not adding this means
unexpected naming convention used in writing, causes problems with my other software interacting with this project
unresolved problem
| TarballURL string | ||
| Ref string | ||
| ZipballUrl string | ||
| ZipballURL string |
There was a problem hiding this comment.
Dangerous JSON Api public, potential problem when creating json from golang
Impact seems to be minor, since this is legacy protocol and c# is case insensitive
There was a problem hiding this comment.
Got you, didn't know the relationship. I can have another PR to fix that repo too if needed. :-)
|
During reading I understood almost every rename is fine, e.g. have a json tag to preserve binary compat |
| _, xmlErr := ToXMLString(&ret.PKey.PublicKey) | ||
| if xmlErr != nil { | ||
| fmt.Printf("convert xml string: %v", xmlErr) | ||
| } |
There was a problem hiding this comment.
this was dead code experimental code from myself
There was a problem hiding this comment.
we may do another cleanup next time.
| } | ||
|
|
||
| func (logger *JobLogger) Append(record protocol.TimelineRecord) *protocol.TimelineRecord { | ||
| func (logger *JobLogger) Append(record *protocol.TimelineRecord) *protocol.TimelineRecord { |
There was a problem hiding this comment.
yes, this is one I forgot the mention in description. It is also discovered by lint tool with below warning
protocol/logger/job_logger.go:415:33: hugeParam: record is heavy (352 bytes); consider passing it by pointer (gocritic)
func (logger *JobLogger) Append(record protocol.TimelineRecord) *protocol.TimelineRecord {
thus, I made the change. Didn't realize it is also used by other repos. Let me know if you want to keep my current change. If yes, I can change other repo too if needed, otherwise, I can revert the change and add some nolint comment. But in my opinion, seems original copy may not be efficient in long live production environment.
| } | ||
|
|
||
| func (logger *JobLogger) Insert(record protocol.TimelineRecord) *protocol.TimelineRecord { | ||
| func (logger *JobLogger) Insert(record *protocol.TimelineRecord) *protocol.TimelineRecord { |
|
Generally yes, I think this can be merged even if it is big. The change rate of this project has declined so, we could make this short and painless @leslie-qiwa In what way do you want to use this project? As a...
Normally I would decide that potential breaking changes should move to 1.0.0 milestone |
|
@ChristopherHX Thanks for quick review. I would use it as a runner application, this is why I'm having this PR as I may create more PRs to improve stability, debug / logging, etc. We have a relative large golang based CI system, now need a self host runner to integrate with it and communicate with our internal resources. Thus your project is perfectly matching our need. :-) |
yes, that is why I'm making the change as json marshall/unmarshal should remain same, only public API need adapt the change. |
The later the CI has static analysis, the more issues people need fix and deal with. :-) So better sooner than later imo. |
|
Some change from your PR causes my runner CI to fail, stricter permissions? This is a mandatory CI check. This readme change pr shows https://github.com/ChristopherHX/github-act-runner/actions/runs/16970040883/job/48104403780?pr=213 that CI passes today and this PR always failed due to permission denied |
|
this is your CI result: https://github.com/ChristopherHX/github-act-runner/actions/runs/16945165477/job/48033615340?pr=212#step:6:1277 Running a non dockerized job after a docker job, or whatever the reason is. |
|
I would merge this PR as soon as CI / run-tests (pull_request) is satisfied. All other things are minor |
| maxRedirects = 10 | ||
| jobTimeout = 5 * time.Minute | ||
| // File permissions | ||
| directoryPermissions = 0664 |
There was a problem hiding this comment.
BUG Copilot revealed the fatal error 0775 is expected
| directoryPermissions = 0664 | |
| directoryPermissions = 0777 |
It is not known if such a change will impact the runner
| directoryPermissions = 0664 | |
| directoryPermissions = 0775 |
However folders need execute rights for enumerating it's content
The cause of the new error is the change in access rights when creating the cache directory:
Before the PR, os.MkdirAll(cacheDir, 0777) was probably used (full rights for everyone).
Now, os.MkdirAll(cacheDir, 0664) is used (no execute permission for directories, and no write permission for “others”).
This is a bug:
Directories require the execute (x) permission, otherwise no one (not even the owner) can enter the directory or create files in it.
0664 makes sense for files, but for directories you MUST use at least 0775 or 0777.
Conclusion:
The error was introduced in the PR by changing os.MkdirAll(cacheDir, 0777) to os.MkdirAll(cacheDir, 0664).
This is the cause of the new “permission denied” when creating ~/.cache/act.
There was a problem hiding this comment.
you are right. I just pushed new change, and will see the result.
total 394 lint issues discovered by the tool. 95% fix is done by copilot
, including several bugs found by lint
1. Run method in actionsrunner/runner.go
actionsrunner/runner.go:147:3: deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop (gocritic)
defer cancelJobListening()
2. io.Read/Write err not check:
ignore most by AI but manually add logging at several places
Signed-off-by: Leslie Qi Wang <qiwa@pensando.io>
|
my installed golangci-lint tool version seems not new as the one used in action, which identified more issues. Let me upgrade and fix. |
|
As far I know golang ci lint is at v2.x already https://github.com/golangci/golangci-lint/releases |
yes, it need use v8.0 of |
|
well now you broke almost all 32bit targets |
|
You know that len(x) of type int at least for 32bit? casting max uint to int is an overflow or some other complaint Do this in a bash shell to get the errors locally |
Signed-off-by: Leslie Qi Wang <qiwa@pensando.io>
|
solved some errors introduced by AI auto fix, but seems more. Just pushed a new change, I used |
|
CI is passing now, ready for merge? |
yes, thanks. |
|
I'll have another PR to upgrade golangci-lint, and enable more lint. |
total 394 lint issues discovered by the tool. 95% fix is done by copilot , including several bugs found by lint
actionsrunner/runner.go:147:3: deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop (gocritic)
defer cancelJobListening()
io.Read/Write err not check: ignore most by AI but manually add logging at several places
3 files were DOS/Windows format.